package ua.khpi.si.kit49.diploma.db.dao;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import ua.khpi.si.kit49.diploma.db.dto.ConnectionFeature;

@Repository("connectionFeatureDAO")
public class ConnectionFeatureDAOImpl implements ConnectionFeatureDAO {

	// /////////////////
	// Queries
	// ////////////////
	private final static String QUERY_GET_CONNECTION_FEATURE_BY_ID = "FROM ConnectionFeature WHERE id_connection = :id";

	@Autowired(required = true)
	private SessionFactory sessionFactory;

	@Override
	public ConnectionFeature getConnectionFeatureById(Integer id) {
		return (ConnectionFeature) sessionFactory.getCurrentSession()
				.createQuery(QUERY_GET_CONNECTION_FEATURE_BY_ID)
				.setParameter("id", id).uniqueResult();
	}

}
